package com.nondo.rdp.finance.endpoint.api.app.stock;

import com.nondo.rdp.auth.endpoint.model.Query;
import com.nondo.rdp.core.model.View;
import com.nondo.rdp.finance.service.MarketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController("apiStockSimulate")
@RequestMapping("/api/stock/simulate")
public class SimulateEndpoint {
    @Autowired
    MarketService marketService;

    @RequestMapping("index")
    public View<Map<String, Object>> openStatus(@RequestBody Query<Map<String, Object>> query) {
        return marketService.simulateIndex(query);
    }

    /**
     * 获取购买列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/list/buy")
    public View<Map<String, Object>> listBuy(@RequestBody Query<Map<String, Object>> query) {
        return marketService.simulateListbuy(query);
    }

    /**
     * 买入股票
     *
     * @param simulateBuyBean
     * @return
     */
    @RequestMapping("/buy")
    public View<Map<String, Object>> buy(@RequestBody Map<String, Object> simulateBuyBean) {
        return marketService.simulateBuy(simulateBuyBean);
    }

    /**
     * 卖出股票
     *
     * @param simulateBuyBean
     * @return
     */
    @RequestMapping("/sale")
    public View<Map<String, Object>> sale(@RequestBody Map<String, Object> simulateBuyBean) {
        return marketService.simulateSale(simulateBuyBean);
    }

    /**
     * 今日成交记录
     *
     * @param query
     * @return
     */
    @RequestMapping("/log/list/today")
    public View<Map<String, Object>> logListToday(@RequestBody Query<Map<String, Object>> query) {
        return marketService.simulateLogListToday(query);
    }

    /**
     * 历史成交记录
     *
     * @param query
     * @return
     */
    @RequestMapping("/log/list")
    public View<Map<String, Object>> logList(@RequestBody Query<Map<String, Object>> query) {
        return marketService.simulateLogList(query);
    }

    /**
     * 获取单支股票信息
     *
     * @param marketBean
     * @return
     */
    @RequestMapping("/getOne")
    public View<Map<String, Object>> getOne(@RequestBody Map<String, Object> marketBean) {
        return marketService.simulateGetOne(marketBean);
    }
}